//
//  CurrencyExchangeJaMATable.m
//  DataCollector
//
//  Created by jiro on 12/06/28.
//  Copyright 2012 jiro music. All rights reserved.
//

#import "CurrencyExchangeJaMa.h"

#import "../../DbConstants.h"
#import "../../DbUtility.h"
#import "libpq-fe.h"
/*
@implementation CurrencyExchangeJaMa

@synthesize averageLength;

+ (CurrencyExchangeJaMa*) currencyExchangeJaMaWithValues: (NSArray*) values
{
	CurrencyExchangeJaMa* ret	= [ [ CurrencyExchangeJaMa alloc ] init ];
	ret.code			= [ values objectAtIndex: 0 ];
	ret.targetCurrencyCode = [ values objectAtIndex: 1 ];
	ret.exchangeDate	= [ NSDate dateWithString: 
		[ DbUtility convertIsoStdDateStringToCocoaDateString: [ values objectAtIndex: 2 ] ] ];
	ret.openPrice		= [ [ values objectAtIndex: 3 ] floatValue ];
	ret.closePrice		= [ [ values objectAtIndex: 4 ] floatValue ];
	ret.highPrice	= [ [ values objectAtIndex: 5 ] floatValue ];
	ret.lowPrice		= [ [ values objectAtIndex: 6 ] floatValue ];
	ret.averageLength	= [ [ values objectAtIndex: 7 ] intValue ];
	return ret;
}

+ (NSString*) tableName
{
	return kText_CurrencyExchangeJaMaTable;
}

+ (NSString*) sourceTableName
{
	return kText_CurrencyExchangeJaTable;
}

+ (NSString*) queryCreateTable
{
	NSString* s = [ NSString stringWithFormat:
		@"create table %@ ( %@ %@, %@ %@, %@ %@, %@ %@, %@ %@, %@ %@, %@ %@, %@ %@, %@( %@, %@, %@, %@ ) );",
			[ CurrencyExchangeJaMa tableName ], 
			kText_Code, kText_Text,
			kText_TargetCurrencyCode, kText_Text,
			kText_ExchangeDate, kText_TimestampWithTimeZone,
			kText_OpenPrice, kText_Real,
			kText_HighPrice, kText_Real,
			kText_LowPrice, kText_Real, 
			kText_ClosePrice, kText_Real,
			kText_AverageLength, kText_Integer,
			kText_PrimaryKey, kText_Code, kText_TargetCurrencyCode, kText_ExchangeDate, kText_AverageLength
	];
	return s;
}

+ (NSString*) querySelectAllWithClauses: (NSArray*) clauses
{
	NSString* s = [ DbTableEntry_ querySelectAllWithTableName: [ CurrencyExchangeJaMa tableName ] andClauses: clauses ];
	return s;
}

+ (NSString*) querySelectFields: (NSArray*) fieldNodes andClauses: (NSArray*) clauses
{
	NSString* s = [ DbTableEntry_ querySelectFields: fieldNodes tableName: [ CurrencyExchangeJaMa tableName ] andClauses: clauses ];
	return s;
}

+ (NSString*) querySelectAll
{
	NSString* s = [ NSString stringWithFormat: @"select * from %@;", [ CurrencyExchangeJaMa tableName ] ];
	return s;
}


- (NSString*) queryInsert
{
	NSString* s = [ NSString stringWithFormat: @"insert into %@ values %@", 
		[ CurrencyExchangeJaMa tableName ], [ self queryInsertValue ] ];
	return s;
}

- (NSString*) queryInsertValue
{
	NSString*s = [ NSString stringWithFormat: @"( '%@', '%@', '%@', %f, %f, %f, %f, %d )",
		self.code, self.targetCurrencyCode, [ self.exchangeDate description ], 
		self.openPrice, self.highPrice, self.lowPrice, self.closePrice, self.averageLength ];
	return s;
}

@end
*/